# GNAFU - "Ground, Navy and Air Fuck-Up" real-time strategy game
# Copyright (C) 2008-2009 k0wax <k0waxk0wax@gmail.com>
#
# This file is part of GNAFU.
#
# GNAFU is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# GNAFU is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNAFU.  If not, see <http://www.gnu.org/licenses/>.

"""Runtime shared variables"""
from __future__ import division, absolute_import
import weakref
from src import xtypes

# it is not a bug if vars.something is not exists
'''
# register vars XXX note bad // need update always if need a new parameter from a class
vars.add(self, 'w h w_px h_px', prefix='field_')
vars.register(self) # add access to self via vars.classname.variable
'''

class Vars(xtypes.DotDict):
    def add_keys(self, fromobj, keys, prefix=''):
        for k in keys.split():
            self.__setitem__(k + prefix, getattr(fromobj, k))
    def add_obj(self, obj, name=None):
        name = name if name else obj.__class__.__name__
        self.__setitem__(name, weakref.proxy(obj))

vars = Vars()

tile_size = 28

